home *** CD-ROM | disk | FTP | other *** search
/ Exploring Where & Why / Exploring Where & Why.iso / pc / Lib.cst / 00063_SinglePoint.ls < prev    next >
Encoding:
Text File  |  2004-07-11  |  2.4 KB  |  117 lines

  1. --
  2. -- SinglePoint
  3. --
  4.  
  5. -- this class handles all runtime game management.
  6.  
  7. -- constants:
  8. property delaySecs  -- the number of seconds we delay before moving on to the next round
  9.  
  10.  
  11. property ancestor
  12. property responseFlag
  13.  
  14. global gUI
  15.  
  16. on new me
  17.   -- initialize constants:
  18.   set delaySecs = 1
  19.   
  20.   set ancestor = new (script "SinglePointPusher")
  21.   
  22.   set responseFlag = TRUE
  23.   
  24.   -- add (the actorList, new (script "ObjectUpdater", me))
  25.   return me
  26. end
  27.  
  28.  
  29. on destruct me
  30.   if objectP (ancestor) then destruct (ancestor)
  31.   set ancestor = 0
  32. end
  33.  
  34.  
  35. on noResponse me
  36.   set responseFlag = FALSE
  37. end
  38.  
  39.  
  40. on initializeRound me
  41.   hideDraggables (me)
  42.   initializeRound (ancestor)
  43.   showDraggables (me)
  44.   pushOffDraggables (me)
  45.   initHandCursor ("hand", getDraggableList (me))
  46.   initPlay (me)
  47. end
  48.  
  49.  
  50. on mouseDown me, spr
  51.   if not isDraggable (me, spr) then return 0
  52.   
  53.   -- drag until release:
  54.   set testSprite = dragSprite (me, spr)
  55.   if testSprite = -1 then return 1  -- drag ended in starting position (exactly)
  56.   
  57.   -- on release of the mouse
  58.   -- check to see if the sprite is overlapping the correct container:
  59.   
  60.   set matchSprite = checkMatch (me, spr, testSprite)
  61.   hideUnderSprite (me)
  62.   
  63.   if matchSprite then
  64.     -- play the good response sound 
  65.     if responseFlag then playResponseSound(1, 1)
  66.     -- play the proper "ID" sound
  67.     playSprite (gUI, spr, #ID)
  68.     -- if so, move the draggable off the screen and animate the 'hit' container:
  69.     hideDraggable (me, spr)
  70.     
  71.     animateSprites (me, [matchSprite])  -- animate the matching sprite
  72.     
  73.     -- move a bar graph if one has been set up:
  74.     moveGraph (me, the name of member the memberNum of sprite matchSprite of castLib the castLibNum of sprite matchSprite)
  75.     
  76.     updateStage
  77.     if not done (me) then 
  78.       initPlay (me)
  79.     end if
  80.     
  81.   else
  82.     showDraggable (me, spr)
  83.     -- play the negative response sound 
  84.     playResponseSound(0, 1)
  85.   end if
  86.   
  87.   return 1
  88. end
  89.  
  90.  
  91.  
  92. -- initialize an individual play:
  93.  
  94. on initPlay me
  95.   set activeSpr = pushOnDraggable (me)
  96.   makePictLink (me, activeSpr)
  97.   -- play the intro sound by sprite...
  98.   playSprite (gUI, activeSpr, #prompt)
  99.   initHandCursor ("hand", getDraggableList (me))
  100. end
  101.  
  102.  
  103.  
  104. -- check to see if we are done.  
  105. -- if so, then do an action.
  106.  
  107. on done me
  108.   clearPictLink (me)
  109.   if checkDone (me) then 
  110.     wait (me, delaySecs)
  111.     go "finish"
  112.     unloadCast (me)
  113.     return 1
  114.   else
  115.     return 0
  116.   end if
  117. end